package chapter1.No1_7_停止线程.f释放锁的不良后果;

/**
 * *：stop方法会为对象解锁，导致数据无法同步从而出现不一致效果
 *
 * @author liujian
 * @version 2016/11/9 0009
 */
public class MyThread extends Thread {
    private SynchronizedObject syncObj;

    public MyThread(SynchronizedObject syncObj) {
        this.syncObj = syncObj;
    }

    @Override
    public void run() {
        syncObj.doLogin("b","bb");
    }

    public static void main(String[] args) throws InterruptedException {
        SynchronizedObject obj = new SynchronizedObject();
        MyThread m1 = new MyThread(obj);
        m1.start();
        Thread.sleep(1000);
        m1.stop();
        System.out.println("userName="+obj.getUserName());
        System.out.println("psw="+obj.getPsw());
    }
}
